#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
	int n;
	cin >> n;

	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}

	sort(a.begin(), a.end());

	auto b = a;
	sort(b.begin(), b.end(), [&](auto &p1, auto &p2) {
		if (p1.second == p2.second) return p1.first < p2.first;
		return p1.second < p2.second;
	});

	if (a != b) {
		cout << "No" << endl;
		return;
	}

	if (a[0].second < a[n - 1].first) {
		cout << "No" << endl;
		return;
	}

	cout << "Yes" << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}